home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / SAMPLES / LISTSTUF.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-09-17  |  1.5 KB  |  81 lines

  1. ; ListStuf.asm-    This file contains all the routines which manipulate the
  2. ;        lists "Randy's Riverside Rally" uses.
  3.  
  4.         include    fpgm.a
  5. cseg        segment    para public 'code'
  6.  
  7. ; CheckPresence-
  8. ;        BX points at an item.  DI points at an item list.  This
  9. ;        routine checks to see if that item is present in the
  10. ;        item list.  Returns Carry set if item was found,
  11. ;        clear if not found.
  12.  
  13. CheckPresence    proc
  14.  
  15. ItemCnt        =    0
  16.         repeat    MaxWeight
  17.         cmp    bx, [di+ItemCnt]
  18.         je    GotIt
  19.  
  20. ItemCnt        =    ItemCnt+2
  21.         endm
  22.  
  23.         clc
  24.         ret
  25.  
  26. GotIt:        stc
  27.         ret
  28. CheckPresence    endp
  29.  
  30.  
  31. ; RemoveItem-    BX contains a pointer to an item.  DI contains a pointer
  32. ;        to an item list which contains that item.  This routine
  33. ;        searches the item list and removes that item from the
  34. ;        list.
  35.  
  36. RemoveItem    proc
  37.  
  38. ItemCnt        =    0
  39.         repeat    MaxWeight
  40.         local    NotThisOne
  41.         cmp    bx, [di+ItemCnt]
  42.         jne    NotThisOne
  43.         mov    word ptr [di], 0
  44.         ret
  45. NotThisOne:
  46. ItemCnt        =    ItemCnt+2
  47.         endm
  48.  
  49.         ret
  50. RemoveItem    endp
  51.  
  52.  
  53. ; InsertItem-    BX contains a pointer to an item, DI contains a pointer to
  54. ;        and item list.  This routine searches through the list for
  55. ;        the first empty spot and copies the value in BX to that point.
  56. ;        It returns the carry set if it succeeds.  It returns the
  57. ;        carry clear if there are no empty spots available.
  58.  
  59. InsertItem    proc
  60.  
  61. ItemCnt        =    0
  62.         repeat    MaxWeight
  63.         local    NotThisOne
  64.         cmp    word ptr [di+ItemCnt], 0
  65.         jne    NotThisOne
  66.         mov    [di], bx
  67.         stc
  68.         ret
  69. NotThisOne:
  70. ItemCnt        =    ItemCnt+2
  71.         endm
  72.  
  73.         clc
  74.         ret
  75. InsertItem    endp
  76. cseg        ends
  77.         end
  78.  
  79.  
  80.  
  81.